/**
 * Copyright (c) Martijn Grootens (m.e.grootens@student.utwente.nl), 
 * University of Twente.
 * Created july 2012.
 *
 * This file is part of dbcleaner.
 * 
 * dbcleaner is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * dbcleaner is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with dbcleaner.  If not, see <http://www.gnu.org/licenses/>.
 */

package dbcleaner.core.fix;

import java.io.*;
import java.util.*;
import dbcleaner.core.dbentries.*;
import dbcleaner.core.parse.*;
import dbcleaner.core.tags.*;
import dbcleaner.core.bibfields.*;

/**
 * Utils that have to do with the (in)completeness of Entries.
 */
public class CompletenessChecker {
    
    /**
     * Append a Tag with name tag to all incomplete Entries in the
     * DataBase db.
     */
    public static int tag_incompletes (DataBase db, String tag) {
        
        int num_tagged = 0;
        
        for (Entry e : db.get_entries()) {
            
            if (e.is_incomplete()) {
                e.add_tag(new Tag(tag));
                ++num_tagged;
            }
            
        }
        
        return num_tagged;
        
    }
    
    /**
     * Append a Tag with name tag to all incomplete Entries in the
     * DataBase db which DO have a doi.
     */
    public static int tag_incompletes_with_doi (DataBase db, String tag) {
        
        int num_tagged = 0;
        
        for (Entry e : db.get_entries()) {
            
            if (e.is_incomplete() && !e.get_field_contents("doi").equals(BibField.EMPTY)) {
                
                e.add_tag(new Tag(tag) );
                ++num_tagged;
            }
                
            
        }
        
        return num_tagged;
        
    }
    
}